package com.ea.eadp.nexus.test.pageDefinition.console;

import org.openqa.selenium.*;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

public class CreateAccountPage extends ConsoleBasePage {

	public CreateAccountPage(WebDriver driver) {
		super(driver, CreateAccountPage.class, "contactMe");
	}

    public void acceptContactMe() {
        this.sendControllerKey('A');
    }

	public void clickContinue() throws Exception {
		//go through contact preference page
        this.sendControllerKey(Keys.DOWN);
		this.sendControllerKey(Keys.DOWN);
		this.sendControllerKey('A');
		
		//Go through thank you page
		this.sendControllerKey(Keys.DOWN);
		this.sendControllerKey('A');
	}

    public String getErrorMessageTitle()
    {
        driver.switchTo().window(this.operationWindowHandle);
        WebDriverWait wait = new WebDriverWait(driver, 30, 1000);
        wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("error-message-title")));
        return driver.findElement(By.id("error-message-title")).getText().trim();
    }
}
